#include "game_screen.h"

bool GameScreen::create()
{
  _background = new Background();
  _background->setColour(Colour::WHITE);
  
  _quit_button = new Button("QUIT");
  
  _column = new Column();
  _column->setSpacing(5);
  _column->add(_quit_button);
  
  GUI_setBackground(_background);
  GUI_setContent(_column);
  
  return true;
}

void GameScreen::destroy()
{
  delete _quit_button;
  delete _column;
  delete _background;
}

void GameScreen::handleKeyDown(const GUIKeyDownEvent* event)
{
  if (event->getKey() == KEY_ESCAPE)
  {
    quit();
  }
}

void GameScreen::handleWidgetEvent(const GUIWidgetEvent* event)
{
  if (event->getEventType() == BUTTON_PRESSED)
  {
    if (event->getWidget() == _quit_button)
    {  
      quit();
    }
  }
}
